package hongvt.quanlynhanvien;

import hongvt.quanlynhanvien.utils.Define;

import java.util.Arrays;

import android.content.Intent;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import butterknife.InjectView;
import butterknife.OnClick;

public class StatiticActivity extends AbstractActivity {

	@InjectView(R.id.month)
	Spinner s_month;

	@InjectView(R.id.year)
	Spinner s_year;

	String[] monthArray;
	String[] yearArray;

	@Override
	protected int getCurrentViewId() {
		// TODO Auto-generated method stub
		return R.layout.activity_statitic;
	}

	@Override
	protected void afterInitView() {

		// for month
		monthArray = getResources().getStringArray(R.array.month);
		ArrayAdapter<String> adt_month = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, Arrays.asList(monthArray));
		adt_month
				.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		s_month.setAdapter(adt_month);

		// for year
		yearArray = getResources().getStringArray(R.array.year);
		ArrayAdapter<String> adt_year = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, Arrays.asList(yearArray));
		adt_year.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		s_year.setAdapter(adt_year);

	}

	@OnClick(R.id.btn_report)
	public void onReport() {
		Intent intent = new Intent(context, ReportActivity.class);
		intent.putExtra(Define.YEAR,
				yearArray[s_year.getSelectedItemPosition()]);
		intent.putExtra(Define.MONTH,
				String.valueOf(s_month.getSelectedItemPosition()));

		startActivity(intent);
	}
}
